import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/auth/weather_entity.dart';

WeatherEntity $WeatherEntityFromJson(Map<String, dynamic> json) {
  final WeatherEntity weatherEntity = WeatherEntity();
  final List<WeatherLives>? lives = (json['lives'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<WeatherLives>(e) as WeatherLives).toList();
  if (lives != null) {
    weatherEntity.lives = lives;
  }
  return weatherEntity;
}

Map<String, dynamic> $WeatherEntityToJson(WeatherEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['lives'] = entity.lives?.map((v) => v.toJson()).toList();
  return data;
}

extension WeatherEntityExtension on WeatherEntity {
  WeatherEntity copyWith({
    List<WeatherLives>? lives,
  }) {
    return WeatherEntity()
      ..lives = lives ?? this.lives;
  }
}

WeatherLives $WeatherLivesFromJson(Map<String, dynamic> json) {
  final WeatherLives weatherLives = WeatherLives();
  final String? province = jsonConvert.convert<String>(json['province']);
  if (province != null) {
    weatherLives.province = province;
  }
  final String? city = jsonConvert.convert<String>(json['city']);
  if (city != null) {
    weatherLives.city = city;
  }
  final String? adcode = jsonConvert.convert<String>(json['adcode']);
  if (adcode != null) {
    weatherLives.adcode = adcode;
  }
  final String? weather = jsonConvert.convert<String>(json['weather']);
  if (weather != null) {
    weatherLives.weather = weather;
  }
  final String? temperature = jsonConvert.convert<String>(json['temperature']);
  if (temperature != null) {
    weatherLives.temperature = temperature;
  }
  final String? winddirection = jsonConvert.convert<String>(json['winddirection']);
  if (winddirection != null) {
    weatherLives.winddirection = winddirection;
  }
  final String? windpower = jsonConvert.convert<String>(json['windpower']);
  if (windpower != null) {
    weatherLives.windpower = windpower;
  }
  final String? humidity = jsonConvert.convert<String>(json['humidity']);
  if (humidity != null) {
    weatherLives.humidity = humidity;
  }
  final String? reporttime = jsonConvert.convert<String>(json['reporttime']);
  if (reporttime != null) {
    weatherLives.reporttime = reporttime;
  }
  final String? temperatureFloat = jsonConvert.convert<String>(json['temperature_float']);
  if (temperatureFloat != null) {
    weatherLives.temperatureFloat = temperatureFloat;
  }
  final String? humidityFloat = jsonConvert.convert<String>(json['humidity_float']);
  if (humidityFloat != null) {
    weatherLives.humidityFloat = humidityFloat;
  }
  return weatherLives;
}

Map<String, dynamic> $WeatherLivesToJson(WeatherLives entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['province'] = entity.province;
  data['city'] = entity.city;
  data['adcode'] = entity.adcode;
  data['weather'] = entity.weather;
  data['temperature'] = entity.temperature;
  data['winddirection'] = entity.winddirection;
  data['windpower'] = entity.windpower;
  data['humidity'] = entity.humidity;
  data['reporttime'] = entity.reporttime;
  data['temperature_float'] = entity.temperatureFloat;
  data['humidity_float'] = entity.humidityFloat;
  return data;
}

extension WeatherLivesExtension on WeatherLives {
  WeatherLives copyWith({
    String? province,
    String? city,
    String? adcode,
    String? weather,
    String? temperature,
    String? winddirection,
    String? windpower,
    String? humidity,
    String? reporttime,
    String? temperatureFloat,
    String? humidityFloat,
  }) {
    return WeatherLives()
      ..province = province ?? this.province
      ..city = city ?? this.city
      ..adcode = adcode ?? this.adcode
      ..weather = weather ?? this.weather
      ..temperature = temperature ?? this.temperature
      ..winddirection = winddirection ?? this.winddirection
      ..windpower = windpower ?? this.windpower
      ..humidity = humidity ?? this.humidity
      ..reporttime = reporttime ?? this.reporttime
      ..temperatureFloat = temperatureFloat ?? this.temperatureFloat
      ..humidityFloat = humidityFloat ?? this.humidityFloat;
  }
}
